< previous page page_423 next page >

Page 423
8694cbadb9b1ef7075903f6f95fc1db2.gif
15:            Screen.MouseIcon = LoadPicture(c:\Program Files\devstudio\_
16: vb\icons\move.ico)
17:     Elself Effect = (vbDropEffectMove Or vbDropEffectScroll) Then
18:            Screen.MousePointer = vbCustom
19:            Screen.MouseIcon = LoadPicture(c:\Program Files\devstudio\_
20: vb\icons\movescrl.ico)
21:     Else
22:            DefaultCursors = True
23:     End If
24: End Sub

Note
The paths used in the preceding code depend on how you installed Visual Basic on your computer.

Caution
You should reset the mousepointers back to the default values in the
OLECompleteDrag event, when the operation is finished.

The OLEDragDrop Event
The OLEDragDrop event is triggered when data is dropped onto the target. If data was placed into the DataObject, it can be retrieved by using the GetData method. The following example retrieves data using the DataObject's GetData method and places it into the target control:
Private Sub picDisplay_OLEDragDrop(Data As VB.DataObject, Effect As Long,_
Button As _
    Integer, Shift As Integer, X As Single, Y As Single)
      txtLastName.Text = Data.GetData(vbCFText)
End Sub
Before accepting the data that is being dropped, you should query the DataObject to check the data type. The GetFormat method is used to check whether the data being dropped is compatible with the target control. If it is, the drop action is completed, as shown in the following code:
Private Sub picDisplay_OLEDragDrop(Data As VB.DataObject, Effect As Long,_
Button As _
  Integer, Shift As Integer, X As Single, Y As Single)
    If Data.GetFormat(vbCFText) Then
       picDisplay.Text = Data.GetData(vbCFText)
    End If
End Sub

 
< previous page page_423 next page >

If you like this book, buy it!